84 read parquet
Reading GeoParquet files and visualizing vector data interactively
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# %pip install -U leafmap lonboard==0.3.0
# %pip install -U leafmap lonboard==0.3.0
In [2]:
Copied!
import leafmap
import leafmap
Visualizing point data.
In [3]:
Copied!
url = 'https://open.gishub.org/data/duckdb/cities.parquet'
url = 'https://open.gishub.org/data/duckdb/cities.parquet'
Read GeoParquet and return a GeoPandas GeoDataFrame.
In [4]:
Copied!
gdf = leafmap.read_parquet(url, return_type='gdf', src_crs='EPSG:4326')
gdf.head()
gdf = leafmap.read_parquet(url, return_type='gdf', src_crs='EPSG:4326')
gdf.head()
Out[4]:
| country | id | latitude | longitude | name | population | geometry | |
|---|---|---|---|---|---|---|---|
| 0 | UGA | 1.0 | 0.5833 | 32.5333 | Bombo | 75000.0 | POINT (32.53330 0.58330) |
| 1 | UGA | 2.0 | 0.6710 | 30.2750 | Fort Portal | 42670.0 | POINT (30.27500 0.67100) |
| 2 | ITA | 3.0 | 40.6420 | 15.7990 | Potenza | 69060.0 | POINT (15.79900 40.64200) |
| 3 | ITA | 4.0 | 41.5630 | 14.6560 | Campobasso | 50762.0 | POINT (14.65600 41.56300) |
| 4 | ITA | 5.0 | 45.7370 | 7.3150 | Aosta | 34062.0 | POINT (7.31500 45.73700) |
View the GeoDataFrame interactively using folium.
In [5]:
Copied!
gdf.explore()
gdf.explore()
Out[5]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Visualize the GeoDataFrame using lonboard.
In [6]:
Copied!
leafmap.view_vector(gdf, get_radius=20000, get_fill_color='blue')
leafmap.view_vector(gdf, get_radius=20000, get_fill_color='blue')
Visualizing polygon data.
In [7]:
Copied!
url = 'https://data.source.coop/giswqs/nwi/wetlands/DC_Wetlands.parquet'
url = 'https://data.source.coop/giswqs/nwi/wetlands/DC_Wetlands.parquet'
In [8]:
Copied!
gdf = leafmap.read_parquet(url, return_type='gdf', src_crs='EPSG:5070', dst_crs='EPSG:4326')
gdf.head()
gdf = leafmap.read_parquet(url, return_type='gdf', src_crs='EPSG:5070', dst_crs='EPSG:4326')
gdf.head()
Out[8]:
| ATTRIBUTE | WETLAND_TYPE | ACRES | Shape_Length | Shape_Area | geometry | |
|---|---|---|---|---|---|---|
| 0 | PEM5Ax | Freshwater Emergent Wetland | 0.454008 | 621.865659 | 1837.304895 | MULTIPOLYGON (((-76.88117 38.98540, -76.88112 ... |
| 1 | PFO1A | Freshwater Forested/Shrub Wetland | 3.339719 | 586.449553 | 13515.364977 | MULTIPOLYGON (((-76.88955 38.98061, -76.88950 ... |
| 2 | PUBHh | Freshwater Pond | 0.873177 | 335.425439 | 3533.620783 | MULTIPOLYGON (((-76.87580 38.98168, -76.87571 ... |
| 3 | R4SBC | Riverine | 0.788316 | 1078.745304 | 3190.202659 | MULTIPOLYGON (((-76.87603 38.98196, -76.87607 ... |
| 4 | R4SBC | Riverine | 0.069572 | 106.791860 | 281.546217 | MULTIPOLYGON (((-76.87472 38.98170, -76.87484 ... |
In [9]:
Copied!
gdf.explore()
gdf.explore()
Out[9]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [10]:
Copied!
leafmap.view_vector(gdf, get_fill_color=[0, 0, 255, 128])
leafmap.view_vector(gdf, get_fill_color=[0, 0, 255, 128])

Alternatively, you can specify a color map to visualize the data.
In [11]:
Copied!
color_map = {
"Freshwater Forested/Shrub Wetland": (0, 136, 55),
"Freshwater Emergent Wetland": (127, 195, 28),
"Freshwater Pond": (104, 140, 192),
"Estuarine and Marine Wetland": (102, 194, 165),
"Riverine": (1, 144, 191),
"Lake": (19, 0, 124),
"Estuarine and Marine Deepwater": (0, 124, 136),
"Other": (178, 134, 86),
}
color_map = {
"Freshwater Forested/Shrub Wetland": (0, 136, 55),
"Freshwater Emergent Wetland": (127, 195, 28),
"Freshwater Pond": (104, 140, 192),
"Estuarine and Marine Wetland": (102, 194, 165),
"Riverine": (1, 144, 191),
"Lake": (19, 0, 124),
"Estuarine and Marine Deepwater": (0, 124, 136),
"Other": (178, 134, 86),
}
In [12]:
Copied!
leafmap.view_vector(gdf, color_column='WETLAND_TYPE', color_map=color_map, opacity=0.5)
leafmap.view_vector(gdf, color_column='WETLAND_TYPE', color_map=color_map, opacity=0.5)

Display a legend for the data.
In [13]:
Copied!
leafmap.Legend(title="Wetland Type", legend_dict=color_map)
leafmap.Legend(title="Wetland Type", legend_dict=color_map)

Last update:
2023-11-27
Created: 2023-11-27
Created: 2023-11-27